package cn.matrix42.potoo.format.markdown.io;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import cn.matrix42.potoo.format.markdown.element.MarkdownElement;

public class MarkdownWriter extends BufferedWriter {

    public MarkdownWriter(String filePath) throws IOException {
        this(filePath, false);
    }

    public MarkdownWriter(String filePath, boolean append) throws IOException {
        super(new FileWriter(filePath, append));
    }

    public void write(MarkdownElement element) throws IOException {
        List<String> contentList = element.toMarkdownStringList();
        for (String line : contentList) {
            write(line);
        }
    }

}
